import React from 'react';
import {Navigate} from "react-router-dom";
import {connect} from "react-redux";

const AuthComponent = (props) => {
  console.log(props)
  return (props.token === undefined || props.token === null || props.token === "") ?
    <Navigate to="/login"/> : props.children
};

const mapStateToProps = (state) => {
  return {
    token: state.userInfo.token
  }
}

export default connect(mapStateToProps, null)(AuthComponent);